/*
 * @Author: 我想吃余 483766615@qq.com
 * @Date: 2025-11-15 21:22:49
 * @LastEditors: 我想吃余 483766615@qq.com
 * @LastEditTime: 2025-11-18 21:06:57
 * @FilePath: /code/oscode/thread_pool/main.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEs
 */
#include <iostream>
#include <unistd.h>
#include <ctime>
#include "Thread.hpp"
//#include "ThreadPoolV1.hpp"
//#include "ThreadPoolV2.hpp"
#include "ThreadPoolV3.hpp"
#include "task.hpp"

using namespace std;

int main()
{
    //threadpool<Task> *tp = new threadpool<Task>(5);
    threadpool<Task>::GetInstance(5)->Init();
    threadpool<Task>::GetInstance(5)->Start();
    srand(time(nullptr)/3);
    int len = opers.size();
    while(true)
    {
        int data1 = rand()%10 +1;
        usleep(10);
        int data2 = rand()%10;
        char op = opers[rand()%len];
        Task t(data1, data2, op);
        threadpool<Task>::GetInstance(5)->Push(t);
        cout << "main thread add a task:" << t.GetTask() << endl;
        sleep(1);
    }

    //delete tp;
    return 0;
}